//
//  TLMeUserTableViewCell.m
//  WXReader
//
//  Created by huaya on 2025/3/18.
//  Copyright © 2025 Andrew. All rights reserved.
//

#import "TLMeUserTableViewCell.h"

@interface TLMeUserTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *ImgView;
@property (weak, nonatomic) IBOutlet UILabel *userNameLab;
@property (weak, nonatomic) IBOutlet UILabel *userIdLab;
@property (weak, nonatomic) IBOutlet UILabel *loginLab;
@property (weak, nonatomic) IBOutlet UIImageView *rightImgView;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topConst;

@end

@implementation TLMeUserTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.bgView.layer.cornerRadius = 8;
    self.ImgView.layer.cornerRadius = 56/2;
    
}
- (IBAction)loginAction:(id)sender {
    
    if (self.didSelectedBlock) {
        self.didSelectedBlock();
    }
    
}
- (void)reloadView{
    
    if (TL_UserInfoManager.isLogin) {
        self.topConst.constant = 24;
        self.loginLab.hidden = YES;
        self.userIdLab.hidden = NO;
        
        _userNameLab.text = TL_UserInfoManager.userInfo.nickName;
        _userIdLab.text = [NSString stringWithFormat:@"ID:%@",TL_UserInfoManager.userInfo.userCardId];
        [_ImgView sd_setImageWithURL:[NSURL URLWithString:TL_UserInfoManager.userInfo.headPic] placeholderImage:[UIImage imageNamed:@"public_avatar.png"]];
        
    }else{
        self.topConst.constant = 16+18;
        self.loginLab.hidden = NO;
        self.userIdLab.hidden = YES;
        _userNameLab.text = WXLocalizedString(@"游客");
        [_ImgView setImage:[UIImage imageNamed:@"public_avatar.png"]];
    }
    
    [self.contentView layoutSubviews];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
